/*
 * srv.h
 *
 *  Created on: Jun 14, 2021
 *      Author: tau
 */

#ifndef SRV_SRV_H_
#define SRV_SRV_H_
#include "board.h"
#define CHIPCHECK 1055
#define FILE_MAX_LENGTH 40960
#define POINT_MAX_COUNTER 4000
#define PID_PARAMETER_MAX_COUNTER 100
//errorCode_e
typedef enum{
	eOK,
	eMEMERY_CHIP_ERROR,
	eCounter,
}errorCode_e;
typedef struct{
	float kp;
	float ki;
	float kd;
}pPID_t;
//sysBase_t
typedef struct{
	bool isUDiskFound;
	int currentWindow;
	int lastWindow;
	bool isPowered;
	time_t beepStartime;
	int errorCode;
	bool isUSBSDAOK;
	bool isUSBSDBOK;
	bool isSysReady;
	unsigned char programeIndex;
	long int  totalCounter;
	long int finishedCounter;
	float nextPoint_f;
	unsigned char nextPoint_u8;

	int programePeriod;
	long int totalTime;
	long int finishedTime;
	bool startFlag;
	bool startFlag_old;
	float pointArray[POINT_MAX_COUNTER];
	pPID_t pPID[PID_PARAMETER_MAX_COUNTER];
	int pidParametesCounter ;

	int pointCounter;
	tResult_t result[3];



}sysBase_t;
//sysConst_t
typedef struct{
	unsigned int chipCheck;
	// 0 CH 1 EN
	unsigned char currentLanguage;
	unsigned char savedProgrameIndex;
	long int  savedTotalCounter;
	long int  savedFinishedCounter;

}sysConst_t;
//sysConst_u
typedef union{
	sysConst_t sysConst;
	char data[sizeof(sysConst_t)];
}sysConst_u;





void srvInit(void);

sysBase_t* getSystemVar(void);
sysConst_u* getSystemConst(void);
void saveSysConst(void);
#endif /* SRV_SRV_H_ */
